package com.itdev.matcherapp.android.fakeservice;

import com.google.android.maps.Point;

public class CalculateUtil {
	public static float getDistanceBetweenLatLong(Point point1, Point point2) {
		float lat1 = (float) (point1.getLatitudeE6() / (1E6));
		float lon1 = (float) (point1.getLongitudeE6() / (1E6));
		float lat2 = (float) (point2.getLatitudeE6() / (1E6));
		float lon2 = (float) (point2.getLongitudeE6() / (1E6));
		double theta = lon1 - lon2;
		double dist = Math.sin(Math.toRadians(lat1)) * Math.sin(Math.toRadians(lat2))
				+ Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2))
				* Math.cos(Math.toRadians(theta));
		dist = Math.acos(dist);
		dist = Math.toDegrees(dist);
		dist = dist * 60 * 1.1515;
		dist = dist * 1.609344;		//to kilometre
		//dist = dist * 0.8684;		//to miles
		return (float) dist;
	}
}
